package com.train.common.utils.id;

/**
 * 雪花算法要保证每个服务器的机器id 和 数据中心id 唯一, 并且要避免时钟回拨
 */
public class SnowIdUtils {

    private static final Long WORK_ID = 1L; //机器id

    private static final Long DATACENTER_ID = 1L; //数据中心id

    public static Long getNextId() {
        SnowflakeIdWorker idWorker = new SnowflakeIdWorker(WORK_ID, DATACENTER_ID);
        return idWorker.nextId();
    }

    public static String getNextIdStr() {
        return String.valueOf(getNextId());
    }
}
